﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="mtahoiatused_hoiatus", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(MtahoiatusedHoiatus))]
    public class MtahoiatusedHoiatusSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IMtahoiatusedHoiatus clazz;
        
        public MtahoiatusedHoiatusSerializer(IMtahoiatusedHoiatus clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("hoiat_id");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.HoiatId))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("ark");
            if (clazz.Ark!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Ark))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("liik");
            if (clazz.Liik!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Liik))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Liik");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("kuupaev");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Kuupaev))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("olek");
            if (clazz.Olek!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Olek))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Olek");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("oleku_muutm_kpv");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.OlekuMuutmKpv))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("maj_paevik_id");
            if (clazz.MajPaevikId!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.MajPaevikId))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("paevik_id");
            if (clazz.PaevikId!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.PaevikId))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="hoiat_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtahoiatused_hoiatus>hoiat_id");
                }
                clazz.HoiatId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("hoiat_id")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtahoiatused_hoiatus>hoiat_id", Reader.LocalName);
            }
            if (Reader.LocalName=="ark") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Ark = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("ark")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtahoiatused_hoiatus>ark", Reader.LocalName);
            }
            if (Reader.LocalName=="liik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtahoiatused_hoiatus>liik");
                }
                clazz.Liik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("liik")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtahoiatused_hoiatus>liik", Reader.LocalName);
            }
            if (Reader.LocalName=="kuupaev") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtahoiatused_hoiatus>kuupaev");
                }
                clazz.Kuupaev = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("kuupaev")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtahoiatused_hoiatus>kuupaev", Reader.LocalName);
            }
            if (Reader.LocalName=="olek") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtahoiatused_hoiatus>olek");
                }
                clazz.Olek = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("olek")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtahoiatused_hoiatus>olek", Reader.LocalName);
            }
            if (Reader.LocalName=="oleku_muutm_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtahoiatused_hoiatus>oleku_muutm_kpv");
                }
                clazz.OlekuMuutmKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("oleku_muutm_kpv")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtahoiatused_hoiatus>oleku_muutm_kpv", Reader.LocalName);
            }
            if (Reader.LocalName=="maj_paevik_id") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.MajPaevikId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("maj_paevik_id")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtahoiatused_hoiatus>maj_paevik_id", Reader.LocalName);
            }
            if (Reader.LocalName=="paevik_id") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.PaevikId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("paevik_id")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtahoiatused_hoiatus>paevik_id", Reader.LocalName);
            }
        }
    }
}
